package com.njworkorder.Service.Impl;

import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njworkorder.Entity.AdministrativeOrganization;
import com.njworkorder.Entity.AdministrativePersonnel;
import com.njworkorder.Service.AdministrativePersonnelService;
import com.njworkorder.Mapper.AdministrativePersonnelMapper;
import com.njworkorder.VO.LoginVo;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;

/**
* @author iron
* @description 针对表【administrative_personnel】的数据库操作Service实现
* @createDate 2024-11-07 14:19:52
*/
@Service
public class AdministrativePersonnelServiceImpl extends MPJBaseServiceImpl<AdministrativePersonnelMapper, AdministrativePersonnel>
    implements AdministrativePersonnelService{

    @Async
    @Override
    public CompletableFuture<LoginVo> getLoginVoByUid(String uid) {
        MPJLambdaWrapper<AdministrativePersonnel> wrapper = new MPJLambdaWrapper<AdministrativePersonnel>()
                .selectAll(AdministrativePersonnel.class)
                .leftJoin(AdministrativeOrganization.class,AdministrativeOrganization::getId, AdministrativePersonnel::getOrganizationId, ext ->
                        ext.selectAs(AdministrativeOrganization::getName, LoginVo::getOrganizationName))
                .eq(AdministrativePersonnel::getUid, uid);
        return CompletableFuture.completedFuture(selectJoinOne(LoginVo.class, wrapper));
    }
}




